#include "window_common.h"

#if defined(GKT_CONFIG_DOOR_LOCK_ENABLE) && GKT_CONFIG_DOOR_LOCK_ENABLE

enum {
	WIDGET_ID_LIST = 0,
	WIDGET_ID_MAX
};

static const gkt_widget_list_item_s sc_window_motor_setting_widget_list_items[] = {
#if !GKT_DOOR_LOCK_MOTOR_ROTATE_DIRECTION_FIXED
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_VOICE_COMBINED_ID(set_1), 
		WINDOW_ID_lock_open_direction),
#endif
#if defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_VOICE_COMBINED_ID(set_2), 
		WINDOW_ID_motor_self_learn),
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_VOICE_COMBINED_ID(set_3), 
		WINDOW_ID_motor_torsion),
	GKT_WIDGET_LIST_STATIC_ITEM(WINDOW_VOICE_COMBINED_ID(set_4), 
		WINDOW_ID_lock_auto_double_close_time),
#endif
};

#define WINDOW_MOTOR_SETTING_LIST_ITEM_NUMS	\
	sizeof(sc_window_motor_setting_widget_list_items) / sizeof(gkt_widget_list_item_s)

static const gkt_widget_list_attr_s sc_window_motor_setting_list_attr = 
	GKT_WIDGET_LIST_STATIC_ATTR(WINDOW_MOTOR_SETTING_LIST_ITEM_NUMS, 
		sc_window_motor_setting_widget_list_items);

GKT_WINDOW_WIDGET_DESCS_DEFINE(motor_setting) = {
	[WIDGET_ID_LIST] = GKT_WIDGET_LIST_DESC(0, &sc_window_motor_setting_list_attr),
};

static int window_motor_setting_event_handler(
				uint32_t major_type, uint32_t minor_type, 
				uint32_t id, uint32_t data)
{
	int retval = GKT_EVENT_HANDLE_CONTINUE;
	gkt_window_id_t window_id;

	switch(major_type) {
		case GKT_EVENT_WINDOW:
			if (GKT_WINDOW_ACTIVE == minor_type)
				window_common_mask_except_number_repeat_return(WINDOW_MOTOR_SETTING_LIST_ITEM_NUMS);
			break;
		case GKT_EVENT_WIDGET:
			if (GKT_WIDGET_EVENT_CLICK == minor_type) {
				window_id = (gkt_window_id_t)sc_window_motor_setting_widget_list_items[data].data;
				gkt_window_show(window_id, 0);
				retval = GKT_EVENT_HANDLE_COMPLETE;
			}
			break;
		default:
			break;
	}

	return retval;
}
GKT_WINDOW_DESC_DEFINE(motor_setting);

#endif

